import type { DataQuery, DataSourceJsonData } from '@grafana/data';

export interface BasicQuery extends DataQuery {
  rawQuery: string;
  constant: number;
  withStreaming: boolean;
}

export const defaultQuery: Partial<BasicQuery> = {
  constant: 6.5,
  withStreaming: false,
};


export interface SQLConnectionLimits {
  maxOpenConns: number;
  maxIdleConns: number;
  connMaxLifetime: number;
}

export interface SQLOptions extends SQLConnectionLimits, DataSourceJsonData {
  tlsAuth: boolean;
  tlsAuthWithCACert: boolean;
  timezone: string;
  tlsSkipVerify: boolean;
  user: string;
  database: string;
  url: string;
  timeInterval: string;
}

/**
 * These are options configured for each DataSource instance
 */
export interface BasicDataSourceOptions extends SQLOptions {
  defaultTimeField?: string;
  tlsConfigurationMethod?: openGaussTLSMethods;
  sslmode?: openGaussTLSModes;
  sslRootCertFile?: string;
  sslCertFile?: string;
  sslKeyFile?: string;
  openGaussVersion?: number;
  timescaledb?: boolean;
}

export enum openGaussTLSModes {
  disable = 'disable',
  require = 'require',
  verifyCA = 'verify-ca',
  verifyFull = 'verify-full',
}

export enum openGaussTLSMethods {
  filePath = 'file-path',
  fileContent = 'file-content',
}

/**
 * Value that is used in the backend, but never sent over HTTP to the frontend
 */
export interface BasicSecureJsonData {
  // apiKey?: string;
  password?: string;
}

export type QueryTypesResponse = {
  queryTypes: string[];
};
